<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:insert="~{include :: header('机构提现详情')}" />
    <th:block th:insert="~{include :: bootstrap-table-css}" />
</head>
<style>
    .ibox h1{
        color: #100de0;
    }
    .fl-tx span{
        padding-left: 30px;
        color: #999;
    }
    .h4-switch span{
        float: right;
    }
</style>
<body class="hold-transition">
<div class="container-fluid mt-2 mb-2">
    <div class="row form-group">
        <div class="col-12">
            <h4>户名：<span th:text="${cashApply.infoName}"></span></h4>
        </div>
    </div>
    <div class="row">
        <div class="col-sm-4">
            <div class="card card-blue">
                <div class="card-header">
                    <div class="card-title">本次提现</div>
                    <div class="card-tools" th:switch="${cashApply.status}">
                        <span th:case="'-1'" class="badge badge-danger">驳回</span>
                        <span th:case="'0'" class="badge badge-warning">未审核</span>
                        <span th:case="'1'" class="label label-success">未支付</span>
                        <span th:case="'2'" class="badge badge-primary">已支付</span>
                    </div>
                </div>
                <div class="card-content text-right pr-2">
                    <h1 th:text="${cashApply.amount/100}+' 元'"></h1>
                </div>
            </div>
        </div>
        <div class="col-sm-4">
            <div class="card card-green">
                <div class="card-header">
                    <div class="card-title">账户余额</div>
                </div>
                <div class="card-content text-right pr-2">
                    <h1 th:text="${amounts}"></h1>
                </div>
            </div>
        </div>
        <div class="col-sm-4">
            <div class="card card-danger">
                <div class="card-header">
                    <div class="card-title">冻结金额</div>
                </div>
                <div class="card-content text-right pr-2">
                    <del><h1 style="color: #DD1144" th:text="${account.frozenAmount/100}+' 元'">0</h1></del>
                </div>
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-12">
            <div class="card">
                <div class="card-header">
                    <h5 class="card-title">收款账户</h5>
                </div>
                <div class="card-body" id="test">
                    <h4 class="h4" th:text="'开户人：'+${cashApply.bankCardName}"></h4>
                    <h4 class="h4" th:text="'开户行：'+${cashApply.bankName}"></h4>
                    <h4 class="h4" th:text="'银行卡：'+${cashApply.bankCardNumber}"></h4>
                </div>
            </div>
        </div>
    </div>
        <div th:if="${cashApply.status==0}" class="row form-group">
            <div class="col-12 text-right">
                <button type="button" class="btn btn-primary" onclick="cashApplyStatus(1)"><i class="fa fa-check"></i>通 过</button>&nbsp;
                <button type="button" class="btn btn-danger" onclick="cashApplyStatus(-1)"><i class="fa fa-reply-all"></i>驳 回</button>
            </div>
        </div>
        <div th:if="${cashApply.status==1}" class="row form-group">
            <div class="col-12 text-right">
                <button type="button" class="btn btn-primary" onclick="cashApplyStatus(2)"><i class="fa fa-check"></i>确认支付</button>&nbsp;
                <button type="button" class="btn btn-danger" onclick="window.parent.layui.layer.closeAll();"><i class="fa fa-reply-all"></i>关闭</button>
            </div>
        </div>
    <h4 class="form-header mt-2">历史提现记录</h4>
    <table id="bootstrap-table" class="table-striped"></table>
</div>
<th:block th:insert="~{include :: footer}" />
<th:block th:insert="~{include :: bootstrap-table-js}" />
<script th:inline="javascript">

    var cashApplyId = [[${cashApply.id}]];

    $(function() {
        var options = {
            url: "/cashapply/list.json",
            modalName: "详情",
            sidePagination: "client",
            showSearch: false,
            showRefresh: false,
            showToggle: false,
            showColumns: false,
            queryParams: queryParams,
            columns: [
                {
                    field: 'id',
                    title: 'ID',
                    visible: false
                },
                {
                    field: 'InfoId',
                    title: 'InfoId',
                    visible: false
                },
                {
                    field: 'bankCardName',
                    title: '开户人'
                },
                {
                    field: 'bankName',
                    title: '开户银行'
                },
                {
                    field: 'bankCardNumber',
                    title: '银行卡号'
                },
                {
                    field: 'amount',
                    title: '提取金额',
                    formatter: function (value, row, index) {
                        return row.amount / 100;
                    }
                },
                {
                    field: 'status',
                    title: '状态',
                    formatter: function (value, row, index) {
                        switch (row.status) {
                            case -1:
                                return '<span class="badge badge-danger">驳回</span>';
                            case 0:
                                return '<span class="badge badge-warning">未审核</span>';
                            case 1:
                                return '<span class="label label-success">未支付</span>';
                            case 2:
                                return '<span class="badge badge-primary">已支付</span>';
                            default:
                                return '-';
                        }
                    }
                },
                {
                    field: 'createTime',
                    title: '申请时间'
                }]
        };
        $.table.init(options);
    });

    function queryParams(params) {
        var search = $.table.queryParams(params);
        search.infoId = [[${cashApply.infoId}]];
        search.type = [[${cashApply.type}]];
        return search;
    }

    //提现审核操作
    function cashApplyStatus(status) {
        var str = "";
        var description = "";
        var url = "/cashapply/apply.json";
        switch (status) {
            case -1:
                str = "请确认是否提现驳回提现申请！";
                description = "审核通过";
                break;
            case 1:
                str = "请确认是否通过提现申请！";
                break;
            case 2:
                str = "请确认是否提现申请状态该为已支付！";
                break;
            default:
        }
        $.modal.confirm(str, function () {
            switch (status) {
                case -1:
                    layer.prompt({title: '请输入备注：', formType: 2}, function (text, index) {
                        description = text;
                        layer.close(index);
                        var data = {"cashApplyId": cashApplyId, "status": status, "description": description};
                        $.operate.submit(url, "post", "json", data);
                        window.parent.layer.closeAll();
                        parent.location.reload();
                    });
                    break;
                case 1:
                    var data = {"cashApplyId": cashApplyId, "status": status, "description": description};
                    $.operate.submit(url, "post", "json", data);
                    window.parent.layer.closeAll();
                    parent.location.reload();
                    break;
                case 2:
                    layer.prompt({title: '请输入备注：', formType: 2}, function (text, index) {
                        description = text;
                        layer.close(index);
                        var data = {"cashApplyId": cashApplyId, "status": status, "description": description};
                        $.operate.submit(url, "post", "json", data);
                        window.parent.layer.closeAll();
                        parent.location.reload();
                    });
                    break;
                default:
                    $.modal.msgError('审核失败，请联系管理员')
            }
        });
    }
</script>
</body>
</html>